﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.LinearSystem
{
	public class Array2D<T> : IInitializableArray<T>
	{
		public int Length0 { get; set; }
		public int Length1 { get; set; }

		public Array2D() { }
		public Array2D(params int[] lengths)
		{
			Initiate(lengths[0], lengths[1]);
		}
		protected T[,] _storage;
		#region IInitializableArray<T> Members

		public void Initiate(params int[] lengths)
		{
			Length0 = lengths[0];
			Length1 = lengths[1];

			_storage = new T[Length0, Length1];
		}

		#endregion

		#region IMultiDimensionalArray<T> Members

		public T this[params int[] index]
		{
			get
			{
				return _storage[index[0], index[1]];
			}
			set
			{
				_storage[index[0], index[1]] = value;
			}
		}

		public int GetLength(int DimensinNumber)
		{
			switch (DimensinNumber)
			{
				case 0: return Length0;
				case 1: return Length1;
				default: return 0;
			}
		}

		public int Dimension
		{
			get { return 2; }
		}

		#endregion
	}
}
